Repository navigation
Escape search query values and resolve typed workspace names - #98522
Conversation
Two mechanisms handled query values and each dropped something. The grammar had no way to write a quotation mark, so a workspace or room called `Acme "US",Inc` could not be expressed and the previous fix silently deleted the quotes. And a name that was typed rather than picked was never mapped to an ID, so the literal text went to the server and the search came back empty. Give the grammar an escape character. A backslash only escapes what the parser would otherwise consume, so a value already stored in a saved search or a shared URL keeps the meaning it has today, including one that contains a lone backslash. Both parsers are regenerated from the shared rules. Ranges now carry the offset and width of the text each part actually matched. Walking the parsed values was only correct while a value and its source were the same length, which escaping breaks, and those ranges position both the substitutions and the live markdown highlighting. Write the escapes in sanitizeSearchValue, and resolve a typed workspace name to its ID when exactly one workspace matches. Names are not unique, so an ambiguous one is left alone rather than guessing. With any value now expressible, the quote stripping workarounds are gone. A comma inside quotes needs no escape, so a value that held one still serializes byte for byte as before and keeps its query hash. Only a value containing a quote or a backslash serializes differently, and those are the values that do not survive a round trip today.
|
@gijoe0295 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
This PR adds a new |
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf92845360
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Submitting a query rebuilds it through buildFilterValuesString, which asked sanitizeSearchValue not to quote commas. A value that holds one was written back bare, so `merchant:Acme\,Inc` and `merchant:"Acme,Inc"` both came out as `merchant:Acme,Inc` and the next read took them as two merchants. The quoted form was already lost this way before the escape character existed. Callers pass one value at a time and join them with commas themselves, so a comma inside a value is always part of it. Quote on it unconditionally and drop the opt in, which only invited a caller to forget it. A list of values is unaffected, since each value is sanitized on its own and only one that contains a comma gains quotes. Take the display name lookup out of the loop that compares it, justify the policy subscription, and read ranges back through the typed autocomplete wrapper so the tests add no assertions.
Resolving a typed workspace name read a module level cache filled by its own Onyx subscription, a second copy of data the callers already hold and one whose timing nothing guarantees. Take the collection as a parameter instead. Every caller is a component or a hook that already reads it, so the value now comes from a subscription that has settled before the render that uses it. Drop the workspace named with a bare comma from the tests. The remaining cases still cover a comma inside a value, which is what the quoting is for, under a name that reads as one workspace rather than two.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c7af07f26
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
No more references to |
I think it is fine, we're only changing the edge cases, but sharing details for product review: For Could you please check the test steps for expected behaviour? Thanks |
Why can't we display the name instead of switching to showing the workspaceID here? |
@trjExpensify we didn't change that logic. This is the same with prod |
|
We are talking about how the values are rendered in search bar when they have special chars as per test step 2 and 3. There is no change to URLs. |
|
Ah, gotcha. I breezed past the URL part. Okay, so we're saying that what is entered or displayed as the workspace name will be shown in the search router and the filter?
I don't think this looks great with the |
|
@parasharrajat please go ahead with final testing/checklist. Thanks |
|
had to go out somewhere today so couldn't catch up here. I will complete it by tomorrow. |
|
@mukhrr Can you please merge main? |
|
@parasharrajat done. let's continue, pls |
There was a problem hiding this comment.
Reviewer Checklist
- I have verified the author checklist is complete (all boxes are checked off).
- I verified the correct issue is linked in the
### Fixed Issuessection above - I verified testing steps are clear and they cover the changes made in this PR
- I verified the steps for local testing are in the
Testssection - I verified the steps for Staging and/or Production testing are in the
QA stepssection - I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
- I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
- I verified the steps for local testing are in the
- I checked that screenshots or videos are included for tests on all platforms
- I included screenshots or videos for tests on all platforms
- I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
- I verified tests pass on all platforms & I tested again on:
- Android: HybridApp
- Android: mWeb Chrome
- iOS: HybridApp
- iOS: mWeb Safari
- MacOS: Chrome / Safari
- If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
- I verified proper code patterns were followed (see Reviewing the code)
- I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e.
toggleReportand notonIconClick). - I verified that comments were added to code that is not self explanatory
- I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
- I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
- I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e.
- If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- I verified that this PR follows the guidelines as stated in the Review Guidelines
- I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like
Avatar, I verified the components usingAvatarhave been tested & I retested again) - If a new component is created I verified that:
- A similar component doesn't exist in the codebase
- All props are defined accurately and each prop has a
/** comment above it */ - The file is named correctly
- The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
- The only data being stored in the state is data necessary for rendering and nothing else
- For Class Components, any internal methods passed to components event handlers are bound to
thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor) - Any internal methods bound to
thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick) - All JSX used for rendering exists in the render method
- The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
- If any new file was added I verified that:
- The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
- If a new CSS style is added I verified that:
- A similar style doesn't already exist
- The style can't be created with an existing StyleUtils function (i.e.
StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
- If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
- If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like
Avataris modified, I verified thatAvataris working as expected in all cases) - If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
- If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
- If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
- I verified that all the inputs inside a form are aligned with each other.
- I added
Designlabel and/or tagged@Expensify/designso the design team can review the changes.
- For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
- If the
mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps. - I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.
Screenshots
🔲 iOS / native
App build is not loading due to some issue, but code changes are platform-agnostic.
🔲 iOS / Safari
21.08.2026_22.21.17_REC.mp4
🔲 MacOS / Chrome
21.08.2026_22.10.23_REC.mp4
🔲 Android / native
21.08.2026_22.17.38_REC.mp4
🎀 👀 🎀 C+ reviewed
|
🚧 Julesssss has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/Julesssss in version: 9.4.60-0 🚀
|
Help site docs review — changes required ✅This PR changes user-facing search operator grammar: a value can now contain a comma (when wrapped in quotes) or a literal quote (escaped with a backslash), and comma-containing values now round-trip correctly instead of splitting into two. The help article Use Search Operators to Filter and Analyze documents this syntax but only covered quoting for spaces/exact phrases — it didn't explain quoting to keep a comma in one value or escaping a literal quote. So a docs update is warranted. Draft PR: #99364 — labeled What was updated
No new UI labels were introduced by this PR (search-query grammar only), so the existing Spend tab / Search icon references stayed as-is.
@mukhrr, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR |
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 9.4.60-2 🚀
Bundle Size Analysis (Sentry): |

Explanation of Change
Adds an escape character to the search grammar so a value containing a quote or a comma can be written at all, writes those escapes in
sanitizeSearchValue, and resolves a typed workspace name to its ID when exactly one workspace matches. The quote-stripping workarounds from #97083 are removed.A backslash only escapes what the parser would otherwise consume, so a value already stored in a saved search or a shared URL keeps its current meaning, including one containing a lone backslash.
Submitting a query rebuilds it, and that rebuild used to write a value holding a comma back out bare, so
merchant:"Globex,Ltd"returned as two merchants. Every value containing a comma is now quoted. A comma separated list is unaffected, since each value is sanitized on its own.Values containing a comma, a quote or a backslash therefore serialize differently than before and their query hash changes. Those are exactly the values that do not survive a round trip today.
Fixed Issues
$ #98374
PROPOSAL:
Tests
Setup: create two workspaces named exactly
Acme, Inc.andAcme "US",Inc.type:expense workspace:"Acme, Inc."and press Enter without clicking a suggestion.policyID:<the workspace's ID>, not the literal name, and the Workspace filter shows that workspace as selected.type:expense workspace:Acmeand click theAcme "US",Incsuggestion.workspace:"Acme \"US\",Inc"— the full name including quotes, notAcme US,Inc.type:expense workspace:"Acme \"US\",Inc"by hand and press Enter.Acme, Inc., reload, and verify the saved search still loads and still shows as saved.from:and pick them.merchant:"Globex,Ltd"and press Enter.category:Travel,Mealsis still treated as two categories.Offline tests
Same as above. Name→ID resolution reads workspaces from Onyx, so it works offline; the search request itself queues as usual.
QA Steps
Same as the Tests section.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
android_app.mp4
Android: mWeb Chrome
android.app.mp4
iOS: Native
ios_app.mp4
iOS: mWeb Safari
IOS-web.mp4
MacOS: Chrome / Safari
web.mp4